var Page = function(){
    this.init();
};
Page.prototype = {
    params: {
        passport: '',
        informationId:''
    },
    init: function(){
        this.initParams();
        this.initEvent();
    },
    initParams: function(){
        this.params.passport = Pub.getCookie('_PASSPORT');

    },
    uploadImg: function(){
        var _this = this;
        Api.upload('#up_form1','#file_1', 'infoimgurl',_this.params.passport, function(response){
            console.log(response);
            if(response.code === 0){
                $('#imgUrl').val(response.data.imgUrl);
                layui.use('layer', function(){
                    layer.msg('上传成功', {icon: 6});
                });
            }
        });

    },
    submit:function(){
        var _this = this;
        $('#submit').click(function(event) {
            var title=$('#title').val();
            var imgUrl=$('#imgUrl').val();
            var ue = UE.getEditor('container');
            var content = ue.getContent();
            var paramsObj = {
                passport: _this.params.passport,
                title:title,
                imgUrl:imgUrl,
                content:content,
            };
            console.log(paramsObj);
            Api.informationmessageadd(paramsObj, function(data){
                console.log(data);
                layui.use('layer', function(){
                    layer.msg('添加成功', {icon: 6});
                    setTimeout(function(){
                        window.location.href = Pub.getHtmlUrl('./information-list.html');
                    },1500)
                });
            });
        });

    },
    otherEvent:function(){
        var _this = this;
        $('.goods-checkbox input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        })

    },
    initEvent: function(){
        var _this = this;
        _this.otherEvent();
        _this.uploadImg();
        _this.submit();



    }
};
var page = new Page();